import React, {PureComponent} from 'react';

class App extends PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            titleSize: 30
        }
    }

    updateTitleSize() {
        this.setState({titleSize: this.state.titleSize + 2})
    }

    render() {
        const {titleSize} = this.state
        return (
            <div>
                <h2 style={{color: "red", fontSize: titleSize}}>我是标题</h2>
                <p style={{color: "red", fontSize: titleSize}}>我是内容,哈哈哈</p>
                <button onClick={() => this.updateTitleSize()}>update</button>
            </div>
        );
    }
}

export default App;

